﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp2
{
    /// <summary>
    /// User1.xaml 的交互逻辑
    /// </summary>
    public partial class User1 : Window
    {
        public Students Students { get; set; }
        public User1()
        {
            InitializeComponent();
        }

        public User1(Students parameter )
        {
            InitializeComponent();
            Students = parameter;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtName.Text.Trim()))
            {
                MessageBox.Show("请填写账号名！！！");
            }
            else if(string.IsNullOrWhiteSpace(txtPassWord.Text.Trim()))
            {
                MessageBox.Show("请填写密码！！！");
            }
            else
            {
                Students = new Students()
                {
                    Name = txtName.Text.Trim(),
                    PassWord = txtPassWord.Text.Trim()
                };
                // 设置DialogResult为true，表示用户点击了“确定”
                this.DialogResult = true;
                Close();
            }  
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            // 设置DialogResult为false，表示用户点击了“取消”
            this.DialogResult = false;
            Close();
        }
    }
}
